/**
 * ZHU framework. Copyright 2012-, all rights reserved.
 *
 * $Id: WebException.java 6 2012-06-19 09:13:09Z zhuxiaopeng $
 * $Revision: 6 $
 * $Date: 2012-06-19 17:13:09 +0800 (二, 2012-06-19) $
 * $Author: zhuxiaopeng $
 */
package zhu.framework.web;

import java.util.*;

/**
 * <p>
 * </p>
 * 
 * @author $Author: zhuxiaopeng $
 * @version $Revision: 6 $ - $Date: 2012-06-19 17:13:09 +0800 (二, 2012-06-19) $
 */
public class WebException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	public WebException() {
		this.detailedMessages = null;
	}

	/**
	 * @param message
	 */
	public WebException(final String message) {
		super(message);
		this.detailedMessages = null;
	}

	/**
	 * @param cause
	 */
	public WebException(final Throwable cause) {
		super(cause);
		this.detailedMessages = null;
	}

	/**
	 * @param message
	 * @param cause
	 */
	public WebException(final String message, final Throwable cause) {
		super(message, cause);
		this.detailedMessages = null;
	}

	/**
     * 
     */
	public WebException(final List<WebMessage> detailedMessages) {
		if (detailedMessages != null) {
			this.detailedMessages = Collections.unmodifiableList(detailedMessages);
		} else {
			this.detailedMessages = null;
		}
	}

	/**
	 * @param message
	 */
	public WebException(final String message, final List<WebMessage> detailedMessages) {
		super(message);
		if (detailedMessages != null) {
			this.detailedMessages = Collections.unmodifiableList(detailedMessages);
		} else {
			this.detailedMessages = null;
		}
	}

	/**
	 * @param cause
	 */
	public WebException(final Throwable cause, final List<WebMessage> detailedMessages) {
		super(cause);
		if (detailedMessages != null) {
			this.detailedMessages = Collections.unmodifiableList(detailedMessages);
		} else {
			this.detailedMessages = null;
		}
	}

	/**
	 * @param message
	 * @param cause
	 */
	public WebException(final String message, final Throwable cause, final List<WebMessage> detailedMessages) {
		super(message, cause);
		if (detailedMessages != null) {
			this.detailedMessages = Collections.unmodifiableList(detailedMessages);
		} else {
			this.detailedMessages = null;
		}
	}

	/**
	 * <p>
	 * この例外に関連づけられた詳細なメッセージの不可変なListを取得する。 メッセージが指定されていない場合は、空のListが返される。
	 * </p>
	 * 
	 * @return 詳細メッセージの不可変なList
	 */
	public List<WebMessage> getDetailedMessages() {
		if (detailedMessages != null) {
			return detailedMessages;
		} else {
			return Collections.unmodifiableList(new ArrayList<WebMessage>());
		}
	}

	private final List<WebMessage> detailedMessages;
}
